package com.slz3.business.module.messageManagement.mesType.steward;

import com.slz3.business.frame.response.RR;
import com.slz3.business.frame.response.ResInfo;
import com.slz3.business.module.messageManagement.mesType.domain.MesType;
import com.slz3.business.module.messageManagement.mesType.domain.MesTypeCondition;
import org.springframework.stereotype.Controller;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;

import javax.annotation.Resource;

@Controller
public class MesTypeResController {

    @Resource
    private MesTypeResAtomic mesTypeResAtomic;

    public Mono<ServerResponse> add(ServerRequest req, MesType mesType) {
        if (MesTypeResUnsafeValid.add(req, mesType)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesTypeResAtomic.add_$MesTypeUpdateLock(req, mesType);
        }
    }

    public Mono<ServerResponse> delete(ServerRequest req, MesTypeCondition mesTypeCondition) {
        if (MesTypeResUnsafeValid.delete(req, mesTypeCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesTypeResAtomic.delete_$MesTypeUpdateLock(req, mesTypeCondition);
        }
    }

    public Mono<ServerResponse> modify(ServerRequest req, MesType mesType) {
        if (MesTypeResUnsafeValid.modify(req, mesType)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesTypeResAtomic.modify_$MesTypeUpdateLock(req, mesType);
        }
    }

    public Mono<ServerResponse> list(ServerRequest req) {
        if (MesTypeResUnsafeValid.list(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return MesTypeResExecutor.list(req);
        }
    }

    public Mono<ServerResponse> info(ServerRequest req) {
//        return mesTypeResAtomic.info_$MesTypeUpdateLock(req);
        if (MesTypeResUnsafeValid.info(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesTypeResAtomic.info_$MesTypeUpdateLock(req);
        }
    }

    public Mono<ServerResponse> choice(ServerRequest req) {
        if (MesTypeResUnsafeValid.choice(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return MesTypeResExecutor.choice(req);
        }
    }

    public Mono<ServerResponse> auditSubmit(ServerRequest req, MesTypeCondition mesTypeCondition) {
        //
        if (MesTypeResUnsafeValid.auditSubmit(req, mesTypeCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesTypeResAtomic.auditSubmit_$MesTypeUpdateLock(req, mesTypeCondition);
        }
    }

    public Mono<ServerResponse> audit(ServerRequest req, MesTypeCondition mesTypeCondition) {
        if (MesTypeResUnsafeValid.audit(req, mesTypeCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesTypeResAtomic.audit_$MesTypeUpdateLock(req, mesTypeCondition);
        }
    }

    public Mono<ServerResponse> auditReject(ServerRequest req, MesTypeCondition mesTypeCondition) {
        if (MesTypeResUnsafeValid.auditReject(req, mesTypeCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesTypeResAtomic.auditReject_$MesTypeUpdateLock(req, mesTypeCondition);
        }
    }

    public Mono<ServerResponse> usingEnable(ServerRequest req, MesTypeCondition mesTypeCondition) {
        if (MesTypeResUnsafeValid.usingEnable(req, mesTypeCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesTypeResAtomic.usingEnable_$MesTypeUpdateLock(req, mesTypeCondition);
        }
    }

    public Mono<ServerResponse> usingDisable(ServerRequest req, MesTypeCondition mesTypeCondition) {
        if (MesTypeResUnsafeValid.usingDisable(req, mesTypeCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesTypeResAtomic.usingDisable_$MesTypeUpdateLock(req, mesTypeCondition);
        }
    }

}
